package com.example.tao_city.mymusicplay;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by TAO_CITY on 2018/3/7.
 */

public class Myadapater extends BaseAdapter {
    private List<SetMusiclist> list;
    private Context context;
    private View pinpuview;

    public Myadapater(List list,Context context){
        this.list=list;
        this.context=context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater layoutInflater=LayoutInflater.from(context);
        convertView=layoutInflater.inflate(R.layout.listviewdemo,null);
        if(convertView!=null){
            TextView text1=convertView.findViewById(R.id.songname);
            TextView text2=convertView.findViewById(R.id.artname);
            RelativeLayout layout=convertView.findViewById(R.id.pingpu);
            text1.setText(list.get(position).getMusicname());
            text2.setText(list.get(position).getMusicArtist());
            layout.addView(pinpuview);
        }
        return convertView;
    }
}
